package com.wydstation.power.properties.repository;

import com.wydstation.power.properties.dto.address.AddressInfo;
import com.wydstation.power.properties.util.UniqueIDUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.r2dbc.core.DatabaseClient;
import org.springframework.stereotype.Repository;

@Repository
public class AddressRepository {


    @Autowired
    private DatabaseClient databaseClient;

    public AddressInfo insertAddress(AddressInfo addressInfo) throws Exception {
        addressInfo.setAddressId(UniqueIDUtil.getUniqueID());
        databaseClient.insert().into(AddressInfo.class).using(addressInfo).then().block();
        return addressInfo;
    }


}
